package com.xl.event.listener;

import com.xl.event.*;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

@Component
public class AlarmEventListener{

    @EventListener
    public void  alarmCreatelistener(AlarmCreateEvent alarmCreateEvent){
        System.err.println("【创建事件监听】："+alarmCreateEvent.getSource().getMessageObj().toString());
        broadCast(alarmCreateEvent);
    }


    @EventListener
    public void  alarmIgnorelistener(AlarmIgnoreEvent ignoreEvent){
        System.err.println("【忽略事件监听】："+ignoreEvent.getSource().getMessageObj().toString());
        broadCast(ignoreEvent);
    }

    @EventListener
    public void  alarmDeletelistener(AlarmDeleteEvent deleteEvent){
        System.err.println("【删除事件监听】："+deleteEvent.getSource().getMessageObj().toString());
        broadCast(deleteEvent);
    }


    public void broadCast(AlaramBasicEvent alaramBasicEvent){
        AlarmInfoSource source = alaramBasicEvent.getSource();
        System.out.println(source.getMessageObj());
    }

}
